package com.benjaminwan.read.free.net.api

import io.reactivex.Observable
import okhttp3.ResponseBody
import retrofit2.http.*

interface HiPDAApi {
    @GET("logging.php?action=login")
    @Headers("User-Agent: read.free", "Cache-Control: no-cache")
    fun getFormHash(
        @Query("referer") referer: String = "https://www.4d4y.com/forum/index.php"
    ): Observable<ResponseBody>

    @POST("logging.php?action=login&loginsubmit=yes&inajax=1")
    @Headers("User-Agent: read.free", "Cache-Control: no-cache")
    @FormUrlEncoded
    fun postLogin(
        @Field("m_formhash") formHash: String,
        @Field("referer") referer: String = "https://www.4d4y.com/forum/index.php",
        @Field("loginfield") loginfield: String = "username",
        @Field("username") username: String,
        @Field("password") password: String,
        @Field("questionid") questionId: String,
        @Field("answer") answer: String,
        @Field("cookietime") cookietime: String = "2592000"
    ): Observable<ResponseBody>

    @GET("forumdisplay.php?")
    @Headers("User-Agent: read.free", "Cache-Control: no-cache")
    fun getForumDisplay(
        @Query("fid") fid: String = "2",
        @Query("page") page: String = "1"
    ): Observable<ResponseBody>

    @GET("pm.php?")
    @Headers("User-Agent: read.free", "Cache-Control: no-cache")
    fun getPM(
        @Query("action") action: String = "viewblack"
    ): Observable<ResponseBody>

    @GET("viewthread.php?")
    @Headers("User-Agent: read.free", "Cache-Control: no-cache")
    fun getThread(
        @Query("tid") tid: String,
        @Query("page") page: String
    ): Observable<ResponseBody>

    @GET("https://www.4d4y.com/config.php")
    @Headers("User-Agent: read.free", "Cache-Control: no-cache")
    fun getCDN(): Observable<ResponseBody>

    @GET("post.php?action=reply")
    @Headers("User-Agent: read.free", "Cache-Control: no-cache")
    fun getPrePost(
        @Query("tid") fid: String
    ): Observable<ResponseBody>

    @POST("post.php?action=reply&replysubmit=yes")
    @Headers("User-Agent: read.free", "Cache-Control: no-cache")
    @FormUrlEncoded
    fun postReply(
        @Query("tid") tid: String,
        @Field("formhash") formhash: String,
        @Field("posttime") posttime: String = System.currentTimeMillis().toString(),
        @Field("wysiwyg") wysiwyg: String = "0",
        @Field("usesig") usesig: String = "1",
        @Field("message") message: String
    ): Observable<ResponseBody>

}